package com.aaa.controller;


import com.aaa.service.UploadService;
import com.aaa.util.LayData;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.PutObjectRequest;
import com.aliyun.oss.model.PutObjectResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

//
//@Controller
//@ResponseBody // 当前的类里面所有的方法返回的都是json
@RestController
@RequestMapping("upload")
public class UploadController {

    //
    @Resource
    private UploadService uploadService;

    @PostMapping
    public LayData upload(MultipartFile file){
        String path = uploadService.uploadFile(file);
        return LayData.success(path);
    }
}
